package com.wc.算法基础课.D第四讲数学知识.求组合数.计算系数;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/4/6 0:03
 * @description https://www.acwing.com/problem/content/213/
 */
public class Main {
    static int P = 10007;
    static int a, b, k, n, m;
    static int N = 1010;
    static int[][] f = new int[N][N];

    static void init() {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0) f[i][j] = 1;
                else f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % P;
            }
        }
    }

    // 系数为C(k,m) a ^ n * b ^ m
    public static void main(String[] args) {
        init();
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        k = sc.nextInt();
        n = sc.nextInt();
        m = sc.nextInt();
        System.out.println(f[k][m] * qkm(a, n) % P * qkm(b, m) % P);
    }

    static long qkm(long a, int b) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) res = res * a % P;
            a = a * a % P;
            b >>= 1;
        }
        return res;
    }
}

